package des.yordan.mihaylov;

/**
 * @author Yordan Mihaylov
 * @version 2011/06/07
 */

public class TDCounter extends Counter {

	private long lastSampleTime;
	private long firstSampleTime;

	// private double lastSampleSize;

	public void count(double value) {
		sumPowerOne += value;
		count++;
	}

	public double getMean() {
		return sumPowerOne / count;
	}

	public long getLastSampleTime() {
		return lastSampleTime;
	}

	public long getFirstSampleTime() {
		return firstSampleTime;
	}

	// when setting an end of an idle period automatically calculate the idle time
	public void setLastSampleTime(long lastSampleTime) {
		this.lastSampleTime = lastSampleTime;
		this.count(lastSampleTime - firstSampleTime);
	}

	public void setFirstSampleTime(long firstSampleTime) {
		this.firstSampleTime = firstSampleTime;
	}

}
